<?php 
$this->load->view('admin/layout/head', array('title'=>'后台管理'), FALSE);
?>

<div id="container">
	<div class="row">
		<div class="col-md-6 col-lg-6">
			<div class="panel panel-default	">
				<div class="panel-heading">
					<b>库存告警</b>
				</div>
				<table class="table">
			    	<thead>
			    		<tr>
			    			<th>商品</th>
			    			<th>规格</th>
			    			<th>剩余库存</th>
			    		</tr>
			    	</thead>
			    	<tbody>
			    		<?php foreach ($danger_stocks as $key => $value): ?>
			    		<tr>
			    			<td>
			    				<a href="/admin/product/edit/<?= $value['id'] ?>"><?= $value['p_title']?></a> 
			    			</td>
			    			<td><?= $value['title'] ?></td>
			    			<td><?= $value['stock'] ?></td>
			    		</tr>
			    		<?php endforeach ?>
			    	</tbody>
			    </table>
		    </div>
			
		</div>
		<div class="col-md-6 col-lg-6">
			<div class="panel panel-default	">
				<div class="panel-heading">
					<b>过期商品</b>
				</div>
				<table class="table">
			    	<thead>
			    		<tr>
			    			<th>商品</th>
			    			<th>规格</th>
			    			<th>过期库存</th>
			    			<th>过期时间</th>
			    		</tr>
			    	</thead>
			    	<tbody>
			    		<?php foreach ($items as $key => $value): ?>
			    		<tr>
			    			<td>
			    				<a href="/admin/purchaseRecord/index?product_id=<?= $value['product_id'] ?>&expire=1"><?= $value['p_title']?></a> 
			    			</td>
			    			<td><?= $value['item_title'] ?></td>
			    			<td><?= $value['stock']*1 ?></td>
			    			<td><?= date('Y-m-d',$value['expire']) ?></td>
			    		</tr>
			    		<?php endforeach ?>
			    	</tbody>
			    </table>
		    </div>
		</div>
		<div class="col-md-12 col-lg-12">
			<div class="panel panel-default	">
				<div class="panel-heading">
					<b>未处理订单</b>
				</div>
				<table class="table">
			    	<thead>
			    		<tr>
			    			<th>订单号</th>
			    			<th>总金额</th>
			    			<th>优惠金额</th>
			    			<th>运费</th>
			    			<th>下单时间</th>
			    			<th>操作</th>
			    		</tr>
			    	</thead>
			    	<tbody>
			    		<?php foreach ($orders as $key => $value): ?>
			    		<tr>
			    			<td><?= $value['order_id'] ?></td>
			    			<td><?= $value['total'] ?></td>
			    			<td><?= $value['cut_fee'] ?></td>
			    			<td><?= $value['shipping_fee'] ?></td>
			    			<td><?= $value['create_time'] ?></td>
			    			<td>
								<a href="/admin/order/detail/<?= $value['id'] ?>">详细</a>
			    			</td>
			    		</tr>
			    		<?php endforeach ?>
			    	</tbody>
			    </table>
		    </div>
			
		</div>
	</div>
</div>

<?php 
$this->load->view('admin/layout/footer');
?>